package wili.sql;

import java.sql.Connection;
import java.sql.DriverManager;

import wili.a.Refs;

/**
 * @author weila 2022年7月24日
 */
public class Conn9a {
	public static Connection hanaDB() {
		return Refs.connectHana1();
	}

	public static Connection sqlserverDB() {
		return null;
	}

	public static Connection mysql(String db) {
		if (db.isEmpty())
			db = "autoeq2";
		return mysql("jdbc:mysql://localhost:3306/", db, "root", "1234");
	}

	public static Connection mysql(String url, String db, String user, String psd) {
		try {
			if ("".isEmpty()) {
				int opt = 1;
				if (opt == 1) {
					url = "jdbc:mysql://localhost:3306/" + db;
					url += "?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT&useSSL=false";
				} else if (opt == 2) {
				}
			}
			//Class.forName("com.mysql.jdbc.Driver");
			Class.forName("com.mysql.cj.jdbc.Driver");//
			Connection ret = DriverManager.getConnection(url, user, psd);
			return ret;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
